<?php 
namespace Home\Model;
use Think\Model;

class FilmClickModel extends Model{
	
	
	public function get_click_num($film_id){
		if(isset($film_id)){
			$num = M('FilmClick')->field('click_num')->where('film_id = '.$film_id)->find();
		}
		return $num['click_num'];
	}
	public function update_click_num($film_id){
		if(isset($film_id)){
			$res = M('FilmClick')->where('film_id = '.$film_id)->count();
			if($res > 0){
				$data=array();
				$data['click_time'] = time();
				M('FilmClick')->where('film_id = '.$film_id)->setInc('click_num',1);
				M('FilmClick')->where('film_id = '.$film_id)->save($data);
				//echo M('FilmClick')->getLastSql();
			}else{
				$data = array();
				$data['film_id'] = $film_id;
				$data['click_num'] = 1;
				$data['click_time'] = time();
				M('FilmClick')->add($data);
			}
			return true;
		}
	}
}




?>